<!--{template ADMIN_DIRECTORY/tpl/admin_header}-->
 {if $_K['map_api']=='baidu'}
<script type="text/javascript" src="{$_K['baidu_api']}"></script>
{else}
<script type="text/javascript" src="{$_K['google_api']}"></script>
{/if}
<div id="div_map">

		<div class="rowElem clearfix mt_5 mb_5">
			<form  method="post">
				 <input type="hidden" name="px" id="px" value="{if $task_info['px']}$task_info['px']{else}30.51667{/if}"/>
						   <input type="hidden" name="py" id="py" value="{if $task_info['py']}$task_info['py']{else}114.31667{/if}"/>					 
						   <input type="hidden" name="zo" id="zo" value="{if $task_info['zo']}$task_info['zo']{else}10{/if}"/>
						   <input type="hidden" name="point" id="point">
						   <input type="hidden" name="province1" id="hdn_province1"/>
	      		<label class="fl_l ml_5">请选择区域</label>
	      		<div id="show_area" class="fl_l mr_5"><select name="province" id="province" ></select><select name="city" id="city"></select><select name="area" id="area"></select></div>
				<label class="fl_l">详细地址</label><input type="text" name="address" size="18" id="address" ><button id="map_search"  type="button" class="ml_5"><span class="icon magnifier"></span>{$_lang['search']}</button>
	    		<button id="sbt_map" type="button" name="sbt_map"  style="*margin-left:5px;"><span class="icon check"></span>确定坐标</button>	
			</form>
		</div>
		<div id="container" style="width:800px;height:300px"></div>
		
		<!--{eval $aa = explode(",",$task_info['province'])}-->					
	</div>
		<!--{eval $local = explode(',',$owner_info['residency']);}-->
<script type="text/javascript" src="../static/js/system/PCASClass.js"></script>
<script type="text/javascript">	
$(function(){new PCAS("province","city","area","{$local['0']}","{$local['1']}","{$local['2']}",'map');});
var myOptions = {center: new google.maps.LatLng(30.937862, 113.937226),	zoom: 4,mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById('container'),myOptions); 
var marker = [];
 google.maps.event.addListener(map, 'click', function(event) {
	clearOverlays();	
	var location = event.latLng;	
	marker.push(new google.maps.Marker({map: map,position: location	}));
	document.getElementById("px").value=results['0'].geometry.location.lat();
	document.getElementById("py").value=results['0'].geometry.location.lng();	
 });


//地图搜索，传入参数为一个详细地址的字符串
function local_search(address){
	 geocoder = new google.maps.Geocoder();
	 geocoder.geocode( { 'address': address}, function(results, status){
	 	if (status == google.maps.GeocoderStatus.OK) {
			clearOverlays();
	 		map.setCenter(results['0'].geometry.location);
			document.getElementById("px").value=results['0'].geometry.location.lat();
			document.getElementById("py").value=results['0'].geometry.location.lng();	
			marker.push(new google.maps.Marker({map: map,position: results['0'].geometry.location	}));
	 	}
	 });
}



function clearOverlays() {
  if (marker) {
    for (var i=0;i<marker.length;i++) {
      marker['i'].setMap(null);
    }
  }
}


{if $owner_info['residency']}
local_search($("#province").val()+','+$("#city").val()+','+$("#address").val());
{/if}

//搜索地址
$("#map_search").click(function(){
		if($("#province").val().length<=0){
				showDialog("{$_lang['please_choose_search_province']}",'alert',"{$_lang['message_notice']}","$('#province').focus()",0);return false;
		}else if($("#city").val().length<=0){
			showDialog("{$_lang['please_choose_search_city']}",'alert',"{$_lang['message_notice']}","$('#city').focus()",0);return false;					
		}else{
			 local_search($("#province").val()+','+$("#city").val()+','+$("#address").val());
			 $("#hdn_province").val($("#province").val()+','+$("#city").val());
			 $("#point").val($("#px").val()+","+$("#py").val());
		}
	}
)

//确定坐标
$("#sbt_map").click(function(){
		if($("#province").val().length<=0){
				showDialog("{$_lang['please_choose_search_province']}",'alert',"{$_lang['message_notice']}","$('#province').focus()",0);return false;
		}else if($("#city").val().length<=0){
			showDialog("{$_lang['please_choose_search_city']}",'alert',"{$_lang['message_notice']}","$('#city').focus()",0);return false;					
		}else{
			 $("#hdn_province").val($("#province").val()+','+$("#city").val());
			 $("#point").val($("#px").val()+","+$("#py").val());
			 if($("#hdn_province").val().length<=0||$("#point").val().length<=0){
			 	showDialog("{$_lang['please_choose_search_province']}",'alert',"{$_lang['message_notice']}","$('#province').focus()",0);return false;
			 }else{
			 	showDialog("坐标确认完成",'right',"操作提示",'qd()');
			 }
		}
	}
)

//province下拉框搜索
function province_search(){
		if($("#province").val().length<=0){
				showDialog("{$_lang['please_choose_search_province']}",'alert',"{$_lang['message_notice']}","$('#province').focus()",0);return false;
		}else{
			 local_search($("#province").val()+','+$("#city").val()+','+$("#address").val());
			 $("#hdn_province").val($("#province").val()+','+$("#city").val());
			 $("#point").val($("#px").val()+","+$("#py").val());
		}
}
function qd(){
	var point = $("#point").val();
	var prov = $("#hdn_province1").val();
	art.dialog.data('mypoint',point);
	art.dialog.data('myprovince',prov);
	art.dialog.close();
}
//city下拉框搜索
function city_search(){
		if($("#province").val().length<=0){
				showDialog("{$_lang['please_choose_search_province']}",'alert',"{$_lang['message_notice']}","$('#province').focus()",0);return false;
		}else if($("#city").val().length<=0){
			showDialog("{$_lang['please_choose_search_city']}",'alert',"{$_lang['message_notice']}","$('#city').focus()",0);return false;					
		}else{
			 local_search($("#province").val()+','+$("#city").val()+','+$("#address").val());
			 $("#hdn_province").val($("#province").val()+','+$("#city").val());
			 $("#point").val($("#px").val()+","+$("#py").val());
		}
}

</script>
<!--{template ADMIN_DIRECTORY/tpl/admin_footer}-->					